/**
 * 
 */
package com.taobao.wolfwolf.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * @author qinanhg
 * 创建日期: 2012-3-16 下午1:24:01
 */
public class ReadIni {
	private String filePath;
	public ReadIni() {
	}
	
	public ReadIni(String filePath) {
		this.filePath = filePath;
	}
	
	/**
	 * 获取属性
	 * @param property
	 * @return
	 */
	public String getProperty(String property) {
		
		Properties p = new Properties();
		
		try {
			FileInputStream inputStream = new FileInputStream(filePath);
			p.load(inputStream);
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		return p.getProperty(property);
	}
	
	public void saveProperty(String property, long value) {
		saveProperty(property, String.valueOf(value));
	}
	
	/**
	 * <p>保存属性</p>
	 * @param property
	 * @param value
	 */
	public void saveProperty(String property, String value) {
		Properties p = new Properties();
		p.setProperty(property, value);
	    FileOutputStream out;
		try {
			out = new FileOutputStream(filePath);
			p.store(out, "save");
			out.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
	}

}
